//文件上传
var v_script_id = 'uploadfile';
//脚本状态,0:该脚本不许执行，1:该脚本可以执行
var v_status = '1';

//脚本逻辑写在run语句之间
if (run){
	var user = action.getSession().getAttribute("user");
	var filedata = 'Filedata';
	//var id = action.dbUtil.getNextId("","h_auth_users", sql);
	action.uploadFile(filedata,'fileupload/'+user.getId(),null,false);
	//获取文件原名
	var sourceFileName = action.vars.get(filedata+'_name');
	var path = action.vars.get(filedata+'_path');
	var size = action.vars.get(filedata+'_size');
	//添加到数据库
	if(sourceFileName!=null && path!=null && size!=null){
		var sql = "insert into h_file_upload (id,userid,filename,filepath,sizes) values(h_file_upload_seq.nextval," + 
			user.getId() + ",'" + sourceFileName + "','" + path + "'," + size + ")";
		if(action.dbUtil.update("",sql)==0){
			action.errorCode = 2;//数据库操作失败
			action.retString = '数据库操作失败';//错误文字说明
		}
	 }
}
	 
